package cn.buk.tms.eotms.controller;

import cn.buk.tms.eotms.response.FlightOrderResponseDto;
import cn.buk.tms.eotms.service.FlightOrderService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletRequest;

import static cn.buk.tms.eotms.util.HttpUtil.getIpAddr;

/**
 * 客户自助服务
 * 未登录用户通过授权码查看订单
 * @author yfdai
 */
@RestController
@RequestMapping("/self-service")
public class SelfServiceController extends BaseController {

    private static final Logger logger = Logger.getLogger(SelfServiceController.class);

    @Autowired
    private FlightOrderService service;


    /**
     * 获取机票订单详情
     * @param code 授权码
     */
    @RequestMapping("/flight/order/{id}")
    public FlightOrderResponseDto getFlightOrderDetail(HttpServletRequest request,
                                                       @PathVariable("id") int id,
                                                       @RequestParam(value = "authCode", required = false) String code,
                                                       @RequestParam(value = "mobile", required = false) String mobile
    ) {
        return service.getFlightOrderDetailByAuthCode(id, code, mobile, getIpAddr(request));
    }

}
